package com.daocheng.dc.book.oss.biz.factory;

import com.daocheng.dc.book.oss.biz.strategy.FileStrategy;
import com.daocheng.dc.book.oss.biz.strategy.impl.AliyunOSSFileStrategy;
import com.daocheng.dc.book.oss.biz.strategy.impl.MinioFileStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName FileStrategyFactory
 * @author: 稻城
 * @date: 2025/3/25
 * @Version 1.0
 * @description: TODO
 */
@Configuration
@RefreshScope
public class FileStrategyFactory {
    @Value("${storage.type}")
    private String strategyType;

    @Bean
    @RefreshScope
    public FileStrategy getFileStrategy() {
        if ("minio".equals(strategyType)) {
            return new MinioFileStrategy();
        } else if ("aliyun".equals(strategyType)) {
            return new AliyunOSSFileStrategy();
        } else {
            throw new RuntimeException("暂不支持该存储类型");
        }
    }
}
